package com.heye.imheye.server;

import lombok.Getter;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

@Component
public class Server {

    @Getter
    private final Map<Long, Set<Long>> chatroom = new ConcurrentHashMap<>();

    public void addChatroomMember(Long chatroomId, Long userId) {
        Set<Long> members = getChatroom().computeIfAbsent(chatroomId, k -> new CopyOnWriteArraySet<>());
        members.add(userId);
    }
}
